package com.fr.schedule.output;

import com.fr.base.XMLable;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;

public class OutputFileFormat
  implements XMLable
{
  public static final String XML_TAG = "OutputFileFormat";
  private static final int CONVERT_TO_CPT = 1;
  private static final int CONVERT_TO_EXCEL = 2;
  private static final int CONVERT_TO_PDF = 4;
  private static final int CONVERT_TO_WORD = 8;
  private int format = 1;

  public OutputFileFormat()
  {
  }

  public OutputFileFormat(boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, boolean paramBoolean4)
  {
    setConvertToCpt(paramBoolean1);
    setConvertToExcel(paramBoolean2);
    setConvertToPdf(paramBoolean3);
    setConvertToWord(paramBoolean4);
  }

  public JSONObject createJSONConfig()
    throws JSONException
  {
    JSONObject localJSONObject = new JSONObject();
    localJSONObject.put("isConvertToCpt", isConvertToCpt());
    localJSONObject.put("isConvertToExcel", isConvertToExcel());
    localJSONObject.put("isConvertToPdf", isConvertToPdf());
    localJSONObject.put("isConvertToWord", isConvertToWord());
    return localJSONObject;
  }

  public static OutputFileFormat analyzeJSON(JSONObject paramJSONObject)
  {
    boolean bool1;
    try
    {
      bool1 = paramJSONObject.getBoolean("isConvertToCpt");
      boolean bool2 = paramJSONObject.getBoolean("isConvertToExcel");
      boolean bool3 = paramJSONObject.getBoolean("isConvertToPdf");
      boolean bool4 = paramJSONObject.getBoolean("isConvertToWord");
      return new OutputFileFormat(bool1, bool2, bool3, bool4);
    }
    catch (JSONException localJSONException)
    {
      localJSONException.printStackTrace();
    }
    return null;
  }

  public void setFormat(int paramInt)
  {
    this.format = paramInt;
  }

  public int getFormat()
  {
    return this.format;
  }

  public boolean isConvertToCpt()
  {
    return ((getFormat() & 0x1) != 0);
  }

  public void setConvertToCpt(boolean paramBoolean)
  {
    if (paramBoolean)
      setFormat(getFormat() | 0x1);
    else
      setFormat(getFormat() & 0xFFFFFFFE);
  }

  public boolean isConvertToExcel()
  {
    return ((getFormat() & 0x2) != 0);
  }

  public void setConvertToExcel(boolean paramBoolean)
  {
    if (paramBoolean)
      setFormat(getFormat() | 0x2);
    else
      setFormat(getFormat() & 0xFFFFFFFD);
  }

  public boolean isConvertToPdf()
  {
    return ((getFormat() & 0x4) != 0);
  }

  public void setConvertToPdf(boolean paramBoolean)
  {
    if (paramBoolean)
      setFormat(getFormat() | 0x4);
    else
      setFormat(getFormat() & 0xFFFFFFFB);
  }

  public boolean isConvertToWord()
  {
    return ((getFormat() & 0x8) != 0);
  }

  public void setConvertToWord(boolean paramBoolean)
  {
    if (paramBoolean)
      setFormat(getFormat() | 0x8);
    else
      setFormat(getFormat() & 0xFFFFFFF7);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
    {
      String str;
      if ((str = paramXMLableReader.getAttr("format")) != null)
        setFormat(Byte.parseByte(str));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("OutputFileFormat").attr("format", getFormat()).end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof OutputFileFormat))
      return false;
    OutputFileFormat localOutputFileFormat = (OutputFileFormat)paramObject;
    return (localOutputFileFormat.getFormat() == getFormat());
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    OutputFileFormat localOutputFileFormat = (OutputFileFormat)super.clone();
    return localOutputFileFormat;
  }
}